package object.obj2D.graphics;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class AnimData {
	//------------------------------------------------------------
	/// declare variable
	//------------------------------------------------------------
	private float y;
	private float x;
	private float m_height;
	private float m_width;
	private long m_timeToLive;
	private float [] m_texture;
	private FloatBuffer m_texBuffer;
	//------------------------------------------------------------
	/// Constructor
	//------------------------------------------------------------
	public AnimData(){
		
	}
	public AnimData(float x, float y, float height, float width) {
		this.setX(x);
		this.setY(y);
		this.setWidth(width);
		this.setHeight(height);
	}

	public FloatBuffer initTexBuffer(){
		m_texture = new float [8];
		m_texture[0] = x;			m_texture[1] = y;
		m_texture[2] = x + m_width;	m_texture[3] = y;
		m_texture[4] = x + m_width;	m_texture[5] = y + m_height;
		m_texture[6] = x;			m_texture[7] = y + m_height;
        ByteBuffer tbb = ByteBuffer.allocateDirect(m_texture.length*4);
        tbb.order(ByteOrder.nativeOrder());
        setTextureBuffer(tbb.asFloatBuffer());
        m_texBuffer.put(m_texture);
        m_texBuffer.position(0);
        return m_texBuffer;
	}
	//------------------------------------------------------------
	/// getter and setter function
	//------------------------------------------------------------
	public void setTimeToLive(long m_timeToLive) {
		this.m_timeToLive = m_timeToLive;
	}

	public long getTimeToLive() {
		return m_timeToLive;
	}

	public void setHeight(float m_height) {
		this.m_height = m_height;
	}

	public float getHeight() {
		return m_height;
	}

	public void setWidth(float m_width) {
		this.m_width = m_width;
	}

	public float getWidth() {
		return m_width;
	}

	public void setX(float x) {
		this.x = x;
	}
	public float getX() {
		return x;
	}
	public void setY(float y) {
		this.y = y;
	}
	public float getY() {
		return y;
	}
	public void setTextureBuffer(FloatBuffer m_texBuffer) {
		this.m_texBuffer = m_texBuffer;
	}
	public FloatBuffer getTexBuffer() {
		return m_texBuffer;
	}
}
